package com.zzyl.controller.manager;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bed")
@Api(tags = "床位管理")
@Slf4j
public class BedController {

    @Autowired
    private BedService bedService;

    @PostMapping("/create")
    @ApiOperation("新增床位")
    public ResponseResult<Void> addBed(@RequestBody BedDto bedDto) {
        log.info("新增床位:{}", bedDto);
        bedService.addBed(bedDto);
        return ResponseResult.success();
    }


    @GetMapping("read/{id}")
    @ApiOperation("根据ID查询床位")
    public ResponseResult<BedVo> findBed(@PathVariable Long id){
        log.info("根据ID查询床位:{}", id);
        BedVo bedVo = bedService.findBed(id);
        return ResponseResult.success(bedVo);
    }


    @PutMapping("update")
    @ApiOperation("更新床位")
    public ResponseResult<Void> updateBed(@RequestBody BedDto bedDto){
        log.info("更新床位:{}", bedDto);
        bedService.updateBed(bedDto);
        return ResponseResult.success();
    }



    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除床位")
    public ResponseResult<Void> deleteBed(@PathVariable Long id){
        log.info("删除床位:{}", id);
        bedService.deleteBed(id);
        return ResponseResult.success();
    }

}
